//
//  BusinessViewCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 16/6/6.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "BusinessViewCell.h"

@interface BusinessViewCell()

@end

@implementation BusinessViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self addUI];
    }
    return self;
}



- (void)addUI
{
    CGFloat Margin = 10;
    
    //商家图片
    self.shopsImg = [[UIImageView alloc] init];
    [self addSubview:_shopsImg];
    
    //商家名字
    self.shopsNameLabel = [[UILabel alloc] init];
    _shopsNameLabel.numberOfLines = 2;
    _shopsNameLabel.font = [UIFont systemFontOfSize:14];
    _shopsNameLabel.font = [UIFont boldSystemFontOfSize:14];
    [self addSubview:_shopsNameLabel];
    
    //商家详情
    self.shopsDetailsLabel = [[UILabel alloc] init];
    _shopsDetailsLabel.font = [UIFont systemFontOfSize:12];
    _shopsDetailsLabel.numberOfLines = 3;
    _shopsDetailsLabel.textColor = [UIColor grayColor];
    [self addSubview:_shopsDetailsLabel];
    
    //商家地址
    self.shopsAddress = [UIButton buttonWithType:UIButtonTypeCustom];
    _shopsAddress.userInteractionEnabled = false;
    [_shopsAddress setImage:[UIImage imageNamed:@"shangjia_1"] forState:UIControlStateNormal];
    _shopsAddress.titleLabel.font = [UIFont systemFontOfSize:10];
    [_shopsAddress setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self addSubview:_shopsAddress];
    _shopsAddress.frame = CGRectMake(WIDTH-WIDTH/6,Margin+5,self.width/6,12);
    _shopsAddress.titleEdgeInsets = UIEdgeInsetsMake(0,5, 0, 0);
    
    self.messageButton = [[UIButton alloc] init];
    [self.messageButton setImage:[UIImage imageNamed:@"23_04"] forState:UIControlStateNormal];
    [self addSubview:self.messageButton];
    
    WeakSelf(self);
    [_shopsImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(weakself.mas_left).offset(Margin);
        make.top.equalTo(weakself.mas_top).offset(Margin);
        make.width.mas_equalTo(WIDTH/2.5);
        make.height.mas_equalTo(HEIGHT/5 - 20);
    }];
    
    [_shopsNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(weakself.shopsImg.mas_right).offset(Margin);
        make.top.equalTo(weakself.mas_top).offset(Margin+5);
        make.width.mas_equalTo(WIDTH-WIDTH/2.5-WIDTH/6-10);
    }];
    
    [_shopsDetailsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(weakself.shopsImg.mas_right).offset(Margin);
        make.top.equalTo(weakself.shopsNameLabel.mas_bottom).offset(Margin);
        make.width.mas_equalTo(WIDTH - WIDTH/2.5-30);
        
    }];
    
    [_messageButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakself.mas_right).offset(-Margin);
        make.bottom.equalTo(weakself.shopsImg);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(50);
    }];
}

@end
